#include "pwm.h"

char count = 0;
char duty = 0;

void timer0_isr() interrupt 1
{
	count++;
	if(count>100) {
		count = 0;
	}
	if(count < duty) {
		PWM_OUT = 1;
	} else {
		PWM_OUT = 0;
	}
	TH0 = 0xFF;
	TL0 = 0xF5;
}

void pwm_init() 
{
	EA = 1; //enable interrupt
	ET0 = 1;//enable timer 0 interrupt
	TMOD |= 0x01;//timer0 16bit mode
	TH0 = 0xFF;
	TL0 = 0xF5; //XTAL=12MHz 10us overflow
	TR0 = 1;//run timer 0
}